fix(exposition): export internal package for OSGi resolution - #2415
fix(exposition): export internal package for OSGi resolution#2415arimu1 wants to merge 5 commits into
Conversation
prometheus-metrics-exposition-textformats imports io.prometheus.metrics.expositionformats.internal because PrometheusProtobufWriter loads the protobuf implementation via Class.forName, but the exposition-formats bundles kept that package private. Export it via bnd _exportcontents so OSGi can wire the two bundles together. Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes OSGi bundle resolution for prometheus-metrics-exposition-textformats by ensuring the implementation package io.prometheus.metrics.expositionformats.internal is exported from the exposition-formats bundles, matching the wiring expected by PrometheusProtobufWriter’s reflective Class.forName loading approach.
Changes:
- Adds bnd (
maven-bundle-plugin) instructions to exportio.prometheus.metrics.expositionformats.internalvia_exportcontentsfor OSGi wiring. - Keeps
io.prometheus.metrics.expositionformats.generated*exported explicitly to preserve existing generated exports. - Applies the same export behavior to both the “formats” and “no-protobuf” bundle-producing modules.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| prometheus-metrics-exposition-formats/pom.xml | Exports the internal implementation package for OSGi resolution while preserving generated package exports. |
| prometheus-metrics-exposition-formats-shaded/pom.xml | Mirrors the same OSGi export instructions for the shaded formats bundle so consumers can resolve the internal package consistently. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jaydeluca
left a comment
There was a problem hiding this comment.
I'm not super familiar with OSGI, so I would like to see some tests or other evidence that this solves the issue if possible
Lock the formats bundle Export-Package and textformats Import-Package headers so OSGi wiring of expositionformats.internal is regression-tested. Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
|
Added
Local Temurin 25: |
Let bnd emit 1.8.1 package versions like sibling bundles. Exclude the phantom protobuf import from the shaded formats bundle, and mark the textformats internal import optional so a textformats-only install still resolves. Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
zeitlinger
left a comment
There was a problem hiding this comment.
Reviewed latest head: CI is green, no merge conflicts, and no blocking review comments remain.
|
Thanks for the contribution! |
|
@arimu1 please fix the format error |
Keep INTERNAL_PACKAGE on one line so flint google-java-format 1.36.1 passes. Signed-off-by: arimu1 <19286898+arimu1@users.noreply.github.com>
Head branch was pushed to by a user without write access
|
Fixed the lint failure: |
Fixes #2395
Summary
io.prometheus.metrics.expositionformats.internalfrom bothprometheus-metrics-exposition-formatsandprometheus-metrics-exposition-formats-no-protobufOSGi bundlesprometheus-metrics-exposition-textformatsimports that package becausePrometheusProtobufWriterloadsPrometheusProtobufWriterImplviaClass.forName, but bnd kept the implementation package private in the formats bundles, so OSGi resolution failedApproach
Used bnd
_exportcontentsto export the otherwise-private internal package while preserving existinggenerated*exports. This matches the metadata wiring fix suggested in the issue (option 1) without moving implementation classes across bundle boundaries.Prove-it (before fix on HEAD)
After fix
Both formats bundles now export
io.prometheus.metrics.expositionformats.internal, satisfying the textformats import.Test plan
mvn -pl prometheus-metrics-exposition-formats,prometheus-metrics-exposition-formats-shaded,prometheus-metrics-exposition-textformats -am test(Java 25)META-INF/MANIFEST.MFin built JARs to confirm internal package is exported and generated exports remain